package com.epro.dx.task;

import java.util.ArrayList;

import com.epro.dx.listenner.MyAsyncTaskListenner;
import com.weipu.common.facade.exception.DxException;
import com.weipu.common.facade.factory.ProviderFactory;
import com.weipu.common.facade.model.ModuleChildrenModel;

import android.os.AsyncTask;

/************************
 * @author Tony
 * @Date:2016-4-14上午10:13:19
 * @描述:获取历史活动列表的任务
 ************************/
public class GetActivityListAsyncTask extends AsyncTask<Void,Void,String> {

	private MyAsyncTaskListenner myAsyncTaskListenner;
	private int pageIndex;
	private int pageSize;
	private ArrayList<ModuleChildrenModel> activityList;
	public GetActivityListAsyncTask(int pageIndex,int pageSize,MyAsyncTaskListenner myAsyncTaskListenner){
		this.pageIndex = pageIndex;
		this.pageSize = pageSize;
		this.myAsyncTaskListenner = myAsyncTaskListenner;
	}
	@Override
	protected void onPreExecute() {
		if(null!=myAsyncTaskListenner){
			myAsyncTaskListenner.onPreTask();
		}
	}
	@Override
	protected String doInBackground(Void... params) {
		try {
			activityList = ProviderFactory.createMainServiceProvider().getActivityList(pageIndex, pageSize);
		} catch (DxException e) {
			return e.getErrCode();
		}
		return "0";
	}
	@Override
	protected void onPostExecute(String result) {
		if(null!=myAsyncTaskListenner){
			myAsyncTaskListenner.onPostTask(result, activityList);
		}
	}

}
